$(function (){
	$('.tabBody tr').on('mouseover', function (){
		$(this).addClass('tabColorTrOver');
	});
	$('.tabBody tr').on('mouseout', function (){
		$(this).removeClass('tabColorTrOver');
	});

	try{
		$("#cardImg").on('mouseover', function() {
			}).on("mouseenter", function() { 
				$('#shimingImg1View').css({"display":""});
				if (IsAbsUrl($id('cardImg').value)){
					$id('shimingImg1View').src=$id('cardImg').value;
				}else{
					$id('shimingImg1View').src=$id('imgDir').value + $id('cardImg').value;
				}
			}).on("mouseleave", function(){
				$('#shimingImg1View').css({"display":"none"});
		});
	}catch (e){}

	try{
		$("#dashangImg1").on('mouseover', function() {
			}).on("mouseenter", function() { 
				$('#img1View').css({"display":""});
				if (IsAbsUrl($id('dashangImg1').value)){
					$id('img1View').src=$id('dashangImg1').value;
				}else{
					$id('img1View').src=$id('imgDir').value + $id('dashangImg1').value;
				}
			}).on("mouseleave", function(){
				$('#img1View').css({"display":"none"});
		});
		$("#dashangImg2").on('mouseover', function() {
			}).on("mouseenter", function() { 
				$('#img2View').css({"display":""});
				if (IsAbsUrl($id('dashangImg2').value)){
					$id('img2View').src=$id('dashangImg2').value;
				}else{
					$id('img2View').src=$id('imgDir').value + $id('dashangImg2').value;
				}
			}).on("mouseleave", function(){
				$('#img2View').css({"display":"none"});
		});
		$("#dashangImg3").on('mouseover', function() {
			}).on("mouseenter", function() { 
				$('#img3View').css({"display":""});
				if (IsAbsUrl($id('dashangImg3').value)){
					$id('img3View').src=$id('dashangImg3').value;
				}else{
					$id('img3View').src=$id('imgDir').value + $id('dashangImg3').value;
				}
			}).on("mouseleave", function(){
				$('#img3View').css({"display":"none"});
		});
	}catch (e){}
});


// 修改信息_类型检测
function CheckRevInfoType(){
	for (var i=0; i<$name("revType").length; i++){
		if ($name("revType")[i].checked==true){
			$id($name("revType")[i].value +"Box").style.display="";
			if ($name("revType")[i].value == "shiming"){
				$id("subBtn").value = " 实名认证完成 ";
			}else{
				$id("subBtn").value = " 提 交 ";
			}
		}else{
			$id($name("revType")[i].value +"Box").style.display="none";
		}
	}
}

// 修改信息_检测表单
function CheckRevForm(){
	var selValue = "";
	for (var i=0; i<$name("revType").length; i++){
		if ($name("revType")[i].checked==true){
			selValue = $name("revType")[i].value;
		}
	}
	if (selValue==""){
		alert("请先选择修改类型.");$name("revType")[0].focus();return false;
	}

	if (selValue=="info"){
		if ($id("realname_must")){
			if ($id("realname_must").value==1 && $id("realname").value==""){alert("昵称不能为空！");$id("realname").focus();return false;}
		}
		if ($id("sex_must")){
			if ($id("sex_must").value==1 && $id("sex1").checked==false && $id("sex0").checked==false){alert("请选择性别！");$id("sex1").focus();return false;}
		}
		if ($id("address_must")){
			if ($id("address_must").value==1 && $id("address").value==""){alert("收货地址不能为空！");$id("address").focus();return false;}
		}
		if ($id("postCode_must")){
			if ($id("postCode_must").value==1 && $id("postCode").value==""){alert("邮编不能为空！");$id("postCode").focus();return false;}
		}
		if ($id("qq_must")){
			if ($id("qq_must").value==1 && $id("qq").value==""){alert("QQ不能为空！");$id("qq").focus();return false;}
		}
		if ($id("weixin_must")){
			if ($id("weixin_must").value==1 && $id("weixin").value==""){alert("微信不能为空！");$id("weixin").focus();return false;}
		}
		if ($id("alipay_must")){
			if ($id("alipay_must").value==1 && $id("alipay").value==""){alert("支付宝不能为空！");$id("alipay").focus();return false;}
		}
		if ($id("ww_must")){
			if ($id("ww_must").value==1 && $id("ww").value==""){alert("旺旺不能为空！");$id("ww").focus();return false;}
		}
		if ($id("web_must")){
			if ($id("web_must").value==1 && $id("web").value==""){alert("个人主页不能为空！");$id("web").focus();return false;}
		}
		if ($id("note_must")){
			if ($id("note_must").value==1 && $id("note").value==""){alert("备注不能为空！");$id("note").focus();return false;}
		}

	}else if (selValue=="username"){
		if ($id("isRevUsername").value=="0"){alert("不允许修改用户名");return false;}
		if ($id("newUsername").value==""){alert("新用户名不能为空！");$id("newUsername").focus();return false;}
		if ($id("newUsername").value.length < 4){alert("新用户名长度不能少于4位！");$id("newUsername").focus();return false;}
		if ($id("newUsername").value!=$id("newUsername2").value){alert("两次用户名不一致！");$id("newUsername2").focus();return false;}

	}else if (selValue=="password"){
		try {
			if ($id("userpwdOld").value==""){alert("原密码不能为空！");$id("userpwdOld").focus();return false;}
		}catch (e) {}
		if ($id("userpwd").value==""){alert("新密码不能为空！");$id("userpwd").focus();return false;}
		if ($id("userpwd").value.length<6){alert("新密码长度不能少于6位！");$id("userpwd").focus();return false;}
		if ($id("userpwd").value!=$id("userpwd2").value){alert("两次密码不一致！");$id("userpwd2").focus();return false;}

	}else if (selValue=="mail"){
		if ($id("isAuthMail").value=="1"){
			if ($id("mail").value==""){alert("当前邮箱不能为空！");$id("mail").focus();return false;}
			if (! IsMail($id("mail").value)){alert("当前邮箱格式错误！");$id("mail").focus();return false;}
			if ($id("mailCode").value==""){alert("邮件验证码不能为空！");$id("mailCode").focus();return false;}
		}else{
			try{
				if ($id("mailOldCode").value==""){alert("当前邮件验证码不能为空！");$id("mailOldCode").focus();return false;}
			}catch (e){}
			if ($id("mail").value==""){alert("新邮箱不能为空！");$id("mail").focus();return false;}
			if (! IsMail($id("mail").value)){alert("新邮箱格式错误！");$id("mail").focus();return false;}
			try{
				if ($id("mailCode").value==""){alert("新邮件验证码不能为空！");$id("mailCode").focus();return false;}
			}catch (e){}
		}
		if ($id("mailPwd").value==""){alert("登录密码不能为空！");$id("mailPwd").focus();return false;}

	}else if (selValue=="phone"){
		if ($id("isAuthPhone").value=="1"){
			if ($id("phone").value==""){alert("当前手机不能为空！");$id("phone").focus();return false;}
			if (! IsPhone($id("phone").value)){alert("当前手机格式错误！");$id("phone").focus();return false;}
			if ($id("phoneCode").value==""){alert("短信验证码不能为空！");$id("phoneCode").focus();return false;}
		}else{
			try{
				if ($id("phoneOldCode").value==""){alert("当前短信验证码不能为空！");$id("phoneOldCode").focus();return false;}
			}catch (e){}
			if ($id("phone").value==""){alert("新手机不能为空！");$id("phone").focus();return false;}
			if (! IsPhone($id("phone").value)){alert("新手机格式错误！");$id("phone").focus();return false;}
			try{
				if ($id("phoneCode").value==""){alert("新短信验证码不能为空！");$id("phoneCode").focus();return false;}
			}catch (e){}
		}
		if ($id("phonePwd").value==""){alert("登录密码不能为空！");$id("phonePwd").focus();return false;}

	}else if (selValue=="question"){
		if ($id("question").value==""){alert("密保问题不能为空！");$id("question").focus();return false;}
		if ($id("answer").value==""){alert("密保答案不能为空！");$id("answer").focus();return false;}

	}else if (selValue=="shiming"){
		if ($id("isShiming").value == 1 || $id("isShiming").value == 11 || $id("isShiming").value == 21){
			alert("实名认证已审核通过，无需再提交。");return false;
		}else if ($id("isShiming").value == 2){
			alert("实名认证正在审核中，请耐心等待，如需加急请联系管理员。");return false;
		}else{
			if ($id("cardType").value==""){alert("请选择 实名认证类型！");$id("cardType").focus();return false;}
			if ($id("cardUser").value==""){alert("实名姓名/公司名 不能为空！");$id("cardUser").focus();return false;}
			if ($id("cardID").value==""){alert("实名身份证号/税号 不能为空！");$id("cardID").focus();return false;}
			/*
			if ($id("cardDealType").value==""){
				alert("请选择 实名认证选择！");$id("cardDealType").focus();return false;
			}else if ($id("cardDealType").value=="weixin" || $id("cardDealType").value=="alipay"){
				CheckShimingRes();return false;
			}else{
				if ($id("cardImg").value==""){alert("实名身份证/营业照 不能为空！");$id("cardImg").focus();return false;}
			}
			*/
			if ($id('cardDealType_upImg') && $id('cardDealType_upImg').checked){
				if ($id("cardImg").value==""){alert("实名身份证/营业照 不能为空！");$id("cardImg").focus();return false;}
			}
			if ($id('cardDealType_weixin') && $id('cardDealType_weixin').checked){
				CheckShimingRes();return false;
			}
			if ($id('cardDealType_alipay') && $id('cardDealType_alipay').checked){
				CheckShimingRes();return false;
			}
		}

	}

//	if (webPathPart=="../"){ $id('revForm').action = webPathPart + $id('revForm').action; }
//	if ($id("verCode").value==""){alert("验证码不能为空！");$id("verCode").focus();return false;}
/*	if (selValue=="face"){
		$id("revForm").target = "DataDeal";
	}else{
		AjaxPostDeal("revForm");
		return false;
	} */
}


// 账号绑定-API解除绑定
function CheckApiCancel(str,strCN){
	if (confirm('确定要解除【'+ strCN +'】绑定？')){
		AjaxGetDeal(jsPathPart +"plugin_deal.php?m=userApiCancel&apiType="+ str);
//		var a=window.open('plugin_deal.php?m=userApiCancel&apiType='+ str);
	}
}

// 账号绑定-增加绑定
function AddApiUser(str){
	if (isMobile == 1){
		var a=window.open("../p.php?m=userApiLogin&id=-1&apiType="+ str);
	}else{
		var a=window.open("../../p.php?m=userApiLogin&id=-1&apiType="+ str);
	}
}


// 提现 表单
function CheckGainMoneyForm(){
	modeStr = '';
	for (var i=0; i<$name("mode").length; i++){
		if ($name("mode")[i].checked){
			modeStr = $name("mode")[i].value; break;
		}
	}

	var money_ = $id('money').value, cutRateStr = "";
	switch (modeStr){
		case 'userMoney':
			if ($id('gainSiteCutRate').value > 0){
				cutMoney = money_ * $id('gainSiteCutRate').value / 100;
				money_ -= cutMoney;
				cutRateStr = "（扣税"+ $id('gainSiteCutRate').value +"%，"+ cutMoney +"元）";
			}
			alertStr = '确定要转入到帐户余额 '+ money_ +' 元'+ cutRateStr +'？';
			break;
	
		case 'alipay':
			if ($id('alipayUser').innerHTML.length == 0){
				alert('支付宝信息尚未填写，请到 左侧【个人信息】-【资料密码修改】填写，格式可以 姓名+支付宝账号');return false;
			}
			if ($id('gainAlipayCutRate').value > 0){
				cutMoney = money_ * $id('gainAlipayCutRate').value / 100;
				money_ -= cutMoney;
				cutRateStr = "（扣税"+ $id('gainAlipayCutRate').value +"%，"+ cutMoney +"元）";
			}
			alertStr = '确定要提现到支付宝 '+ money_ +' 元'+ cutRateStr +'？\n支付宝信息：'+ $id('alipayUser').innerHTML +'\n\n请认真检查 姓名和支付宝账号 是否正确？\n如支付宝信息错误请到 左侧【个人信息】-【资料密码修改】修改，格式可以 姓名+支付宝账号。\n如支付宝账号错误导致提现错人概不负责。';
			break;
	
		case 'weixin':
			if ($id('weixinUser').innerHTML.length == 0){
				alert('微信信息尚未填写，请到 左侧【个人信息】-【资料密码修改】填写，格式可以 昵称+微信号');return false;
			}
			if ($id('gainWeixinCutRate').value > 0){
				cutMoney = money_ * $id('gainWeixinCutRate').value / 100;
				money_ -= cutMoney;
				cutRateStr = "（扣税"+ $id('gainWeixinCutRate').value +"%，"+ cutMoney +"元）";
			}
			alertStr = '确定要提现到微信 '+ money_ +' 元'+ cutRateStr +'？\n微信信息：'+ $id('weixinUser').innerHTML +'\n\n请认真检查 昵称和微信号 是否正确？\n如微信信息错误请到 左侧【个人信息】-【资料密码修改】修改，格式可以 昵称+微信号\n如微信号错误导致提现错人概不负责。';
			break;
	
		case 'diy':
			if ($id('gainDiyCutRate').value > 0){
				cutMoney = money_ * $id('gainDiyCutRate').value / 100;
				money_ -= cutMoney;
				cutRateStr = "（扣税"+ $id('gainDiyCutRate').value +"%，"+ cutMoney +"元）";
			}
			alertStr = '确定要提现到【'+ $id('diyUser').innerHTML +'】 '+ money_ +' 元'+ cutRateStr +'？';
			break;
	
		default:
			alert('请先选择提现方式');return false;
			break;
	}

	if (ToFloat($id('money').value) == 0){
		alert("请输入要提现的金额");$id("money").focus();return false;
	}

	if (confirm(alertStr)){
		$id('resMoney').value = money_;
		AjaxPostDeal("moneyForm");
		return false;
	}else{
		return false;
	}
}


// 积分兑换佣金 表单
function CheckGainScoreForm(){
	var currMoney = ToInt($id('scoreMoney').value);

	if (confirm("你确定要积分兑换佣金 "+ currMoney +" 元？")){
		$id('resScore1').value = $id('gainScore1Box').innerHTML;
		$id('resScore2').value = $id('gainScore2Box').innerHTML;
		$id('resScore3').value = $id('gainScore3Box').innerHTML;
		AjaxPostDeal("scoreForm");
		return false;
	}else{
		return false;
	}
}


// 实时显示积分兑换佣金信息
function ShowGainScoreVal(){
	var currMoney = ToInt($id('scoreMoney').value);
	var currScore1 = currMoney * $id('gainScore1').value
	var currScore2 = currMoney * $id('gainScore2').value
	var currScore3 = currMoney * $id('gainScore3').value
	$id('gainScore1Box').innerHTML = currScore1;
	$id('gainScore2Box').innerHTML = currScore2;
	$id('gainScore3Box').innerHTML = currScore3;
	$id('resScore1').value = $id('gainScore1Box').innerHTML;
	$id('resScore2').value = $id('gainScore2Box').innerHTML;
	$id('resScore3').value = $id('gainScore3Box').innerHTML;
}

// 每页显示数量
function RevUserPageNum(page){
	document.location.href = "usersCenter_deal.php?mudi=revPageNum&pageNum="+ page +"&backUrl="+ encodeURIComponent(document.location.href);
}

// API授权码 重新生成/关闭授权
function MakeNewApiKey(str){
	if (str == "empty"){
		alertStr = '确定要关闭授权？\n关闭后，授权码会被清空。';
	}else{
		alertStr = '确定要重新生成授权码？\n重新生成后，之前的授权码就会失效。';
	}
	if (confirm(alertStr)){
		AjaxGetDeal(jsPathPart +"plugin_deal.php?m=apiKey&mode="+ str);
	}
}

// 提现记录
function CheckRecomMoneyForm(){
	if (ToFloat($id('money').value) == 0){
		alert("请输入要提现的金额");$id("money").focus();return false;
	}
	if ($id('mode_userMoney').checked){
		alertStr = '确定要转入到帐户余额 '+ $id('money').value +' 元？';
	}else{
		alertStr = '确定要提现到支付宝 '+ $id('money').value +' 元？\n支付宝：'+ $id('alipayMail').innerHTML +'（姓名：'+ $id('alipayUser').innerHTML +'）\n\n请认真检查 姓名和支付宝账号 是否正确？\n如支付宝账号错误导致提现错人概不负责。';
	}
	if (confirm(alertStr)){
		AjaxPostDeal("moneyForm");
		return false;
	}else{
		return false;
	}
}

function CheckShiming(){
	switch ($id('cardType').value){
		case '身份证':
			$id('shimingUser').innerHTML = "姓名：";
			$id('shimingID').innerHTML = "身份证号：";
			$id('shimingImgFile').innerHTML = "身份证电子版：";
			break;
	
		case '营业执照':
			$id('shimingUser').innerHTML = "公司名称：";
			$id('shimingID').innerHTML = "税号：";
			$id('shimingImgFile').innerHTML = "营业执照电子版：";
			break;
	
		case '其他':
			$id('shimingUser').innerHTML = "其他1：";
			$id('shimingID').innerHTML = "其他2：";
			$id('shimingImgFile').innerHTML = "其他图片：";
			break;
	
	}
}

function CheckShimingDeal(){
	$id('shimingUpImg').style.display = "none";
	$id('shimingWeixin').style.display = "none";
	$id('shimingAlipay').style.display = "none";
	/*
	switch ($id('cardDealType').value){
		case 'upImg':
			$id('shimingUpImg').style.display = "";
			$id('shimingUserNote').innerHTML = "";
			$id('shimingIDNote').innerHTML = "";
			break;
	
		case 'weixin':
			$id('shimingWeixin').style.display = "";
			$id('shimingUserNote').innerHTML = "（与微信实名姓名一致）";
			$id('shimingIDNote').innerHTML = "（与微信实名身份证号一致）";
			break;
	
		case 'alipay':
			$id('shimingAlipay').style.display = "";
			$id('shimingUserNote').innerHTML = "（与支付宝实名姓名一致）";
			$id('shimingIDNote').innerHTML = "（与支付宝实名身份证号一致）";
			break;
	}
	*/
	if ($id('cardDealType_upImg') && $id('cardDealType_upImg').checked){
		$id('shimingUpImg').style.display = "";
		$id('shimingUserNote').innerHTML = "";
		$id('shimingIDNote').innerHTML = "";
	}
	if ($id('cardDealType_weixin') && $id('cardDealType_weixin').checked){
		$id('shimingWeixin').style.display = "";
		$id('shimingUserNote').innerHTML = "（与微信实名姓名一致）";
		$id('shimingIDNote').innerHTML = "（与微信实名身份证号一致）";
	}
	if ($id('cardDealType_alipay') && $id('cardDealType_alipay').checked){
		$id('shimingAlipay').style.display = "";
		$id('shimingUserNote').innerHTML = "（与支付宝实名姓名一致）";
		$id('shimingIDNote').innerHTML = "（与支付宝实名身份证号一致）";
	}
}

// 获取实名认证-微信扫码
function GetShimingWeixin(){
	//var a=window.open('plugin_deal.php?m=shimingWeixin&shimingType='+ encodeURIComponent($id('cardType').value) +'&shimingUser='+ encodeURIComponent($id('cardUser').value) +'&shimingID='+ encodeURIComponent($id('cardID').value));
	AjaxGetDealToId('plugin_deal.php?m=shimingWeixin&shimingType='+ encodeURIComponent($id('cardType').value) +'&shimingUser='+ encodeURIComponent($id('cardUser').value) +'&shimingID='+ encodeURIComponent($id('cardID').value), 'weixinQrBox');
}

// 获取实名认证-支付宝扫码
function GetShimingAlipay(){
	//var a=window.open('plugin_deal.php?m=shimingAlipay&shimingType='+ encodeURIComponent($id('cardType').value) +'&shimingUser='+ encodeURIComponent($id('cardUser').value) +'&shimingID='+ encodeURIComponent($id('cardID').value));
	AjaxGetDealToId('plugin_deal.php?m=shimingAlipay&shimingType='+ encodeURIComponent($id('cardType').value) +'&shimingUser='+ encodeURIComponent($id('cardUser').value) +'&shimingID='+ encodeURIComponent($id('cardID').value), 'alipayQrBox');
}

// 检测实名认证结果
function CheckShimingRes(){
	var cardDealTypeVal = "";
	if ($id('cardDealType_weixin') && $id('cardDealType_weixin').checked){
		cardDealTypeVal = "weixin";
	}
	if ($id('cardDealType_alipay') && $id('cardDealType_alipay').checked){
		cardDealTypeVal = "alipay";
	}
	//var a=window.open('plugin_deal.php?m=shimingAlipay&shimingType='+ encodeURIComponent($id('cardType').value) +'&shimingUser='+ encodeURIComponent($id('cardUser').value) +'&shimingID='+ encodeURIComponent($id('cardID').value));
	AjaxGetDeal('plugin_deal.php?m=shimingRes&type='+ cardDealTypeVal);
}
// 会员退出  放在js/inc/common.js


// 功能单页
function CheckOnePageForm(){
	if ($id("title").value==""){alert("网站名称 不能为空！");$id("title").focus();return false;}
}


// 音乐视频表单
function CheckAudioVideoForm(){
	if ($id("type").value==""){alert("请先选择 类型！");$id("type").focus();return false;}
	if ($id("theme").value==""){alert("标题 不能为空！");$id("theme").focus();return false;}
	if ($id("file").value==""){alert("文件地址 不能为空！");$id("file").focus();return false;}
	return true;
}
